package com.vehicle.biz.core.support.impl;

import com.vehicle.biz.core.support.abs.AbstractSupport;
import com.vehicle.constants.Constants;
import com.vehicle.domains.ctx.PlateDetectContext;
import com.vehicle.domains.entity.CameraEntity;
import com.vehicle.domains.entity.VehicleCommonLedgerEntity;
import com.vehicle.domains.entity.VehicleTransportLedgerEntity;
import com.vehicle.domains.info.InternalVehicleInfo;
import com.vehicle.enums.VehicleTypeEnum;
import com.vehicle.exception.VehicleAccessException;
import com.vehicle.service.VehicleCommonLedgerService;
import com.vehicle.service.config.SystemConfig;
import com.vehicle.service.config.SystemConfigService;
import com.vehicle.utils.Base64ToImageUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class CommonSupport extends AbstractSupport {
    @Resource
    private SystemConfigService systemConfigService;

    @Resource
    private VehicleCommonLedgerService vehicleCommonLedgerService;

    public String getSupportName() {
        return VehicleTypeEnum.COMMON.name();
    }

    @Override
    public void processOut(PlateDetectContext plateDetectContext) {
        //禁止没有录入车辆信息的车辆出去
        if (plateDetectContext.getCommonVehicleEntity() == null) {
            if (systemConfigService.get(SystemConfig.exitPassValid)) {
                throw VehicleAccessException.SYSTEM_ERROR.newInstance("车辆未录入！！！");
            } else {
                plateDetectContext.setVehicleType(VehicleTypeEnum.COMMON.name());
            }
        }
    }
}
